package cn.tedu.mintmall.controller;

import cn.tedu.mintmall.dto.ProductDetailsDTO;
import cn.tedu.mintmall.restful.JsonResult;
import cn.tedu.mintmall.service.IProductDetails;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/details")
@Api("商品详情模块")
public class ProductDetailsController {
    @Autowired
    private IProductDetails productDetails;
    @PostMapping("/add")
    @ApiOperation("新增商品详情")
    public JsonResult addDetails(ProductDetailsDTO productDetailsDTO){
        productDetails.addProductDetails(productDetailsDTO);
        return JsonResult.ok("新增商品详情成功");
    }
    @DeleteMapping("/delete")
    @ApiOperation("删除商品详情")
    @ApiImplicitParam(value = "商品id",dataType = "Integer",required =true,defaultValue = "1")
    public JsonResult deleteDetails(Integer productId){
        productDetails.deleteDetails(productId);
        return JsonResult.ok("删除完成!");
    }
    @PostMapping("/update")
    @ApiOperation("修改商品详情")
    public JsonResult updateDetails(ProductDetailsDTO productDTO){
        productDetails.updateDetails(productDTO);
        return JsonResult.ok("修改完成");
    }
    @GetMapping("/update")
    @ApiOperation("查询商品详情")
    public JsonResult queryDetails(Integer productId){
        productDetails.queryDetails(productId);
        return JsonResult.ok("修改完成");
    }

}
